<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 25] 25.55 java.lang.Short (JDK 1.1)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:27:37 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_54.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 25<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch25_56.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-55">25.55 java.lang.Short (JDK 1.1)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-55.1"></A></h3>
</DIV>

<P CLASS=para>
This class provides an object wrapper around the
<tt CLASS=literal>short</tt> primitive type.  It defines useful constants
for the minimum and maximum values that can be stored by the
<tt CLASS=literal>short</tt> type, and also a <tt CLASS=literal>Class</tt> object constant
that represents the <tt CLASS=literal>short</tt> type.  It also provides
various methods for converting <tt CLASS=literal>Short</tt> values to and
from strings and other numeric types.

<P CLASS=para>
Most of the static methods of this class are used to convert
a <tt CLASS=literal>String</tt> to a <tt CLASS=literal>Short</tt> object or a <tt CLASS=literal>short</tt>
value: the four <tt CLASS=literal>parseShort()</tt> and <tt CLASS=literal>valueOf()</tt>
methods parse a number from the specified string, using an
optionally specified radix, and return it in one of these two
forms.  The <tt CLASS=literal>decode()</tt> method parses a number specified
in base 10, base 8, or base 16 and returns it as a
<tt CLASS=literal>Short</tt>.  If the string begins with "0x" or "#", it is
interpreted as a hexadecimal number, or if it begins with
"0", it is interpreted as an octal number. Otherwise, it is
interpreted as a decimal number.

<P CLASS=para>
Note that this class has two different <tt CLASS=literal>toString()</tt>
methods.  One is static and converts a <tt CLASS=literal>short</tt>
primitive value to a String.  The other is the usual
<tt CLASS=literal>toString()</tt> method that converts a <tt CLASS=literal>Short</tt>
object to a string.  Most of the remaining methods convert a
<tt CLASS=literal>Short</tt> to various primitive numeric types.

<DIV CLASS=screen>
<P>
<PRE>
public final class <tt CLASS=literal>Short</tt> extends Number {
    // <tt CLASS=literal>Public Constructors</tt>
            public <tt CLASS=literal>Short</tt>(short <tt CLASS=literal>value</tt>);
            public <tt CLASS=literal>Short</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
    // <tt CLASS=literal>Constants</tt>
            public static final short <tt CLASS=literal>MAX_VALUE</tt>;
            public static final short <tt CLASS=literal>MIN_VALUE</tt>;
            public static final Class <tt CLASS=literal>TYPE</tt>;
    // <tt CLASS=literal>Class Methods</tt>
            public static Short <tt CLASS=literal>decode</tt>(String <tt CLASS=literal>nm</tt>) throws NumberFormatException;
            public static short <tt CLASS=literal>parseShort</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
            public static short <tt CLASS=literal>parseShort</tt>(String <tt CLASS=literal>s</tt>, int <tt CLASS=literal>radix</tt>) throws NumberFormatException;
            public static String <tt CLASS=literal>toString</tt>(short <tt CLASS=literal>s</tt>);
            public static Short <tt CLASS=literal>valueOf</tt>(String <tt CLASS=literal>s</tt>, int <tt CLASS=literal>radix</tt>) throws NumberFormatException;
            public static Short <tt CLASS=literal>valueOf</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
    // <tt CLASS=literal>Public Instance Methods</tt>
            public byte <tt CLASS=literal>byteValue</tt>();  //<tt CLASS=literal> Overrides Number</tt>
            public double <tt CLASS=literal>doubleValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public boolean <tt CLASS=literal>equals</tt>(Object <tt CLASS=literal>obj</tt>);  //<tt CLASS=literal> Overrides Object</tt>
            public float <tt CLASS=literal>floatValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public int <tt CLASS=literal>hashCode</tt>();  //<tt CLASS=literal> Overrides Object</tt>
            public int <tt CLASS=literal>intValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public long <tt CLASS=literal>longValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public short <tt CLASS=literal>shortValue</tt>();  //<tt CLASS=literal> Overrides Number</tt>
            public String <tt CLASS=literal>toString</tt>();  //<tt CLASS=literal> Overrides Object</tt>
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-55.2">Hierarchy:</A></h3>

<P CLASS=para>
Object->Number(Serializable)->Short

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-55.3">Returned By:</A></h3>

<P CLASS=para>
Short.decode(), 
Short.valueOf()

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_54.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch25_56.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.lang.SecurityManager (JDK 1.0)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.lang.StackOverflowError (JDK 1.0)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
